package com.wawei.seeds.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.wawei.seeds.R;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 *
 * Created by t27891 on 15/6/28.
 */
public class WalnutServiceDetailItemActivityAdapter extends SeedsBaseAdapter<WalnutMainActivityAdapter.WalnutEventAppointmentMan> {
    public WalnutServiceDetailItemActivityAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder viewHolder;
        if(null == view){
            view = LayoutInflater.from(context).inflate(R.layout.fragment_walnut_me_service_detail_item, parent, false);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        }
        else {
            viewHolder = (ViewHolder)view.getTag();
        }

        WalnutMainActivityAdapter.WalnutEventAppointmentMan man = (WalnutMainActivityAdapter.WalnutEventAppointmentMan)getItem(position);
        if(null != man.headPortrait && man.headPortrait.length() > 0){
            imageLoader.loadImage(man.headPortrait, viewHolder.bookerLogo, true, false);
        }
        viewHolder.bookerAlias.setText(man.userName);
        viewHolder.bookerStatus.setText(man.appointmentStatus);
        viewHolder.bookerTime.setText(man.appointmentTime);

        return view;
    }

    static class ViewHolder{
        @InjectView(R.id.item_appointment_hero_logo)ImageView bookerLogo;
        @InjectView(R.id.item_appointment_man_alias)TextView bookerAlias;
        @InjectView(R.id.item_appointment_status)TextView bookerStatus;
        @InjectView(R.id.item_appointment_time)TextView bookerTime;

        public ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
